window.addEventListener("load", () => {
  class Login {
    constructor() {
      this.init();
      this.bindevent();
    }

    init() {
      $("#txtCustomerID").val(localStorage.getItem("uname"));
      $("#txtPassword").val(localStorage.getItem("pwd"));
    }
    bindevent() {
      $(".user-default-btn").on("click", () => {
        this.login();
      });
    }
    login() {
      var uname_id=$("#txtCustomerID").val()
      if (
        $("#txtCustomerID").val() === localStorage.getItem("uname") &&
        $("#txtPassword").val() === localStorage.getItem("pwd")
      ) {
        if ($(":checkbox").prop("checked") == true) {
          $.cookie("uname", $("#txtCustomerID").val());
          $.cookie("pwd", $("#txtPassword").val());
        } 
        location.href = "../dist/index.html#name=" + uname_id;
      } else {
        alert("失败");
      }
    }
  }

  new Login();
});
